public class Solution944 {
    public int minDeletionSize(String[] strs) {
        int ans=0;
        for (int i=0;i<strs[0].length();i++){
            for (int j=0;j<strs.length-1;j++){
                if (strs[j].charAt(i)>strs[j+1].charAt(i)){
                    ans++;
                    break;
                }
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new Solution944().minDeletionSize(new String[]{"cba","daf","ghi"}));
    }
}
